package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.filesystem.File;
	import flash.net.URLRequest;
	
	import mx.rpc.IResponder;
	
	public class FileAccessHelper
	{
		private var responder : IResponder;
		private    var pictLdr:Loader;
		public function FileAccessHelper(responder:IResponder)
		{
			this.responder = responder;
		}
		public function loadPNGFile(name:String, fromApplicationStorage:Boolean) : void
		{			
			var file:File ;
			if( fromApplicationStorage ) {
				file = File.applicationStorageDirectory.resolvePath(name);
			} else {
				file = File.applicationDirectory.resolvePath(name);
			}
			
			trace(file.url);
			pictLdr = new Loader();			
		  	pictLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, onPNGImgLoaded);			
		  	pictLdr.load(new URLRequest(file.url));	
		}
		public function onPNGImgLoaded(event:Event):void {	
			var pictLoad:Bitmap = Bitmap(pictLdr.content);
			responder.result(pictLoad.bitmapData);
		}
		
		

	}
}